#include <stdlib.h>
#include <iostream>
#include <string>
#include <fstream>
#include <algorithm>
#include <sstream>
#include "ctest.h"
#include "../Blaster/bullet.h"
#include "../Blaster/menu.h"
#include "../Blaster/meteor.h"
#include "../Blaster/music.h"
#include "../Blaster/rocket.h"


CTEST(suite1, test1){
    Rocket r;
    float expected_s = float(0.13);
    ASSERT_EQUAL(r.s, expected_s);
}

CTEST(suite1, test2){
    Rocket r;
    double expected_currentFrame = double(0);
    ASSERT_EQUAL(r.currentFrame, expected_currentFrame);
}

CTEST(suite1, test3){
    Bullet b(0.0f, 1, 0.0f, 0.0f);
    float expected_speed = 0.0f;
    ASSERT_EQUAL(b.speed, expected_speed);
}

CTEST(suite1, test4){
    Meteor m (10.0f, 0.0f, 0, 1, sf::Vector2f(100.0f, 100.0f));
    float expected_speed = 0.0f;
    ASSERT_EQUAL(m.speed, expected_speed);
}

CTEST(suite1, test5){
    Rocket r;
    double Time = 5.0;
    double expectedIncrement = 0.0009 * Time;
    r.update(Time, sf::Vector2f(0.0f, 0.0f));
    ASSERT_EQUAL(r.currentFrame, expectedIncrement);
}


//тесты на открытие картинок
CTEST(suite2, test1) {
    std::string path_image = "../../Blaster/cmake-build-debug/Image/";
    path_image += "bullet.png";
    std::ifstream fin;
    fin.open(path_image);
    bool check = true;
    if (!fin.is_open()){
        check = false;
    }
    ASSERT_EQUAL(check, true);
}

CTEST(suite2, test2) {
    std::string path_image = "../../Blaster/cmake-build-debug/Image/";
    path_image += "exit.png";
    std::ifstream fin;
    fin.open(path_image);
    bool check = true;
    if (!fin.is_open()){
        check = false;
    }
    ASSERT_EQUAL(check, true);
}

CTEST(suite2, test3) {
    std::string path_image = "../../Blaster/cmake-build-debug/Image/";
    path_image += "exit_star.png";
    std::ifstream fin;
    fin.open(path_image);
    bool check = true;
    if (!fin.is_open()){
        check = false;
    }
    ASSERT_EQUAL(check, true);
}

CTEST(suite2, test4) {
    std::string path_image = "../../Blaster/cmake-build-debug/Image/";
    path_image += "HP.png";
    std::ifstream fin;
    fin.open(path_image);
    bool check = true;
    if (!fin.is_open()){
        check = false;
    }
    ASSERT_EQUAL(check, true);
}

CTEST(suite2, test5) {
    std::string path_image = "../../Blaster/cmake-build-debug/Image/";
    path_image += "icon.png";
    std::ifstream fin;
    fin.open(path_image);
    bool check = true;
    if (!fin.is_open()){
        check = false;
    }
    ASSERT_EQUAL(check, true);
}

CTEST(suite2, test6) {
    std::string path_image = "../../Blaster/cmake-build-debug/Image/";
    path_image += "kometa.png";
    std::ifstream fin;
    fin.open(path_image);
    bool check = true;
    if (!fin.is_open()){
        check = false;
    }
    ASSERT_EQUAL(check, true);
}

CTEST(suite2, test7) {
    std::string path_image = "../../Blaster/cmake-build-debug/Image/";
    path_image += "kometa0.png";
    std::ifstream fin;
    fin.open(path_image);
    bool check = true;
    if (!fin.is_open()){
        check = false;
    }
    ASSERT_EQUAL(check, true);
}

CTEST(suite2, test8) {
    std::string path_image = "../../Blaster/cmake-build-debug/Image/";
    path_image += "kometa1.png";
    std::ifstream fin;
    fin.open(path_image);
    bool check = true;
    if (!fin.is_open()){
        check = false;
    }
    ASSERT_EQUAL(check, true);
}

CTEST(suite2, test9) {
    std::string path_image = "../../Blaster/cmake-build-debug/Image/";
    path_image += "kometa2.png";
    std::ifstream fin;
    fin.open(path_image);
    bool check = true;
    if (!fin.is_open()){
        check = false;
    }
    ASSERT_EQUAL(check, true);
}

CTEST(suite2, test10) {
    std::string path_image = "../../Blaster/cmake-build-debug/Image/";
    path_image += "kometa3.png";
    std::ifstream fin;
    fin.open(path_image);
    bool check = true;
    if (!fin.is_open()){
        check = false;
    }
    ASSERT_EQUAL(check, true);
}

CTEST(suite2, test11) {\
    std::string path_image = "../../Blaster/cmake-build-debug/Image/";
    path_image += "kometa4.png";
    std::ifstream fin;
    fin.open(path_image);
    bool check = true;
    if (!fin.is_open()){
        check = false;
    }
    ASSERT_EQUAL(check, true);
}

CTEST(suite2, test12) {
    std::string path_image = "../../Blaster/cmake-build-debug/Image/";
    path_image += "kometa5.png";
    std::ifstream fin;
    fin.open(path_image);
    bool check = true;
    if (!fin.is_open()){
        check = false;
    }
    ASSERT_EQUAL(check, true);
}

CTEST(suite2, test13) {
    std::string path_image = "../../Blaster/cmake-build-debug/Image/";
    path_image += "kometa6.png";
    std::ifstream fin;
    fin.open(path_image);
    bool check = true;
    if (!fin.is_open()){
        check = false;
    }
    ASSERT_EQUAL(check, true);
}

CTEST(suite2, test14) {
    std::string path_image = "../../Blaster/cmake-build-debug/Image/";
    path_image += "kometa7.png";
    std::ifstream fin;
    fin.open(path_image);
    bool check = true;
    if (!fin.is_open()){
        check = false;
    }
    ASSERT_EQUAL(check, true);
}

CTEST(suite2, test15) {
    std::string path_image = "../../Blaster/cmake-build-debug/Image/";
    path_image += "kometa8.png";
    std::ifstream fin;
    fin.open(path_image);
    bool check = true;
    if (!fin.is_open()){
        check = false;
    }
    ASSERT_EQUAL(check, true);
}

CTEST(suite2, test16) {
    std::string path_image = "../../Blaster/cmake-build-debug/Image/";
    path_image += "kometa9.png";
    std::ifstream fin;
    fin.open(path_image);
    bool check = true;
    if (!fin.is_open()){
        check = false;
    }
    ASSERT_EQUAL(check, true);
}

CTEST(suite2, test17) {
    std::string path_image = "../../Blaster/cmake-build-debug/Image/";
    path_image += "kometa10.png";
    std::ifstream fin;
    fin.open(path_image);
    bool check = true;
    if (!fin.is_open()){
        check = false;
    }
    ASSERT_EQUAL(check, true);
}

CTEST(suite2, test18) {
    std::string path_image = "../../Blaster/cmake-build-debug/Image/";
    path_image += "kometa11.png";
    std::ifstream fin;
    fin.open(path_image);
    bool check = true;
    if (!fin.is_open()){
        check = false;
    }
    ASSERT_EQUAL(check, true);
}

CTEST(suite2, test19) {
    std::string path_image = "../../Blaster/cmake-build-debug/Image/";
    path_image += "menu0.png";
    std::ifstream fin;
    fin.open(path_image);
    bool check = true;
    if (!fin.is_open()){
        check = false;
    }
    ASSERT_EQUAL(check, true);
}

CTEST(suite2, test20) {
    std::string path_image = "../../Blaster/cmake-build-debug/Image/";
    path_image += "menu1.png";
    std::ifstream fin;
    fin.open(path_image);
    bool check = true;
    if (!fin.is_open()){
        check = false;
    }
    ASSERT_EQUAL(check, true);
}

CTEST(suite2, test21) {
    std::string path_image = "../../Blaster/cmake-build-debug/Image/";
    path_image += "menu2.png";
    std::ifstream fin;
    fin.open(path_image);
    bool check = true;
    if (!fin.is_open()){
        check = false;
    }
    ASSERT_EQUAL(check, true);
}

CTEST(suite2, test22) {
    std::string path_image = "../../Blaster/cmake-build-debug/Image/";
    path_image += "menu3.png";
    std::ifstream fin;
    fin.open(path_image);
    bool check = true;
    if (!fin.is_open()){
        check = false;
    }
    ASSERT_EQUAL(check, true);
}

CTEST(suite2, test23) {
    std::string path_image = "../../Blaster/cmake-build-debug/Image/";
    path_image += "menu4.png";
    std::ifstream fin;
    fin.open(path_image);
    bool check = true;
    if (!fin.is_open()){
        check = false;
    }
    ASSERT_EQUAL(check, true);
}

CTEST(suite2, test25) {
    std::string path_image = "../../Blaster/cmake-build-debug/Image/";
    path_image += "menu5.png";
    std::ifstream fin;
    fin.open(path_image);
    bool check = true;
    if (!fin.is_open()){
        check = false;
    }
    ASSERT_EQUAL(check, true);
}

CTEST(suite2, test26) {
    std::string path_image = "../../Blaster/cmake-build-debug/Image/";
    path_image += "menu6.png";
    std::ifstream fin;
    fin.open(path_image);
    bool check = true;
    if (!fin.is_open()){
        check = false;
    }
    ASSERT_EQUAL(check, true);
}

CTEST(suite2, test27) {
    std::string path_image = "../../Blaster/cmake-build-debug/Image/";
    path_image += "menu7.png";
    std::ifstream fin;
    fin.open(path_image);
    bool check = true;
    if (!fin.is_open()){
        check = false;
    }
    ASSERT_EQUAL(check, true);
}

CTEST(suite2, test28) {
    std::string path_image = "../../Blaster/cmake-build-debug/Image/";
    path_image += "menu8.png";
    std::ifstream fin;
    fin.open(path_image);
    bool check = true;
    if (!fin.is_open()){
        check = false;
    }
    ASSERT_EQUAL(check, true);
}

CTEST(suite2, test29) {
    std::string path_image = "../../Blaster/cmake-build-debug/Image/";
    path_image += "menu9.png";
    std::ifstream fin;
    fin.open(path_image);
    bool check = true;
    if (!fin.is_open()){
        check = false;
    }
    ASSERT_EQUAL(check, true);
}

CTEST(suite2, test30) {
    std::string path_image = "../../Blaster/cmake-build-debug/Image/";
    path_image += "menu10.png";
    std::ifstream fin;
    fin.open(path_image);
    bool check = true;
    if (!fin.is_open()){
        check = false;
    }
    ASSERT_EQUAL(check, true);
}

CTEST(suite2, test31) {
    std::string path_image = "../../Blaster/cmake-build-debug/Image/";
    path_image += "menu11.png";
    std::ifstream fin;
    fin.open(path_image);
    bool check = true;
    if (!fin.is_open()){
        check = false;
    }
    ASSERT_EQUAL(check, true);
}

CTEST(suite2, test32) {
    std::string path_image = "../../Blaster/cmake-build-debug/Image/";
    path_image += "menu12.png";
    std::ifstream fin;
    fin.open(path_image);
    bool check = true;
    if (!fin.is_open()){
        check = false;
    }
    ASSERT_EQUAL(check, true);
}

CTEST(suite2, test33) {
    std::string path_image = "../../Blaster/cmake-build-debug/Image/";
    path_image += "menuBackground.png";
    std::ifstream fin;
    fin.open(path_image);
    bool check = true;
    if (!fin.is_open()){
        check = false;
    }
    ASSERT_EQUAL(check, true);
}

CTEST(suite2, test34) {
    std::string path_image = "../../Blaster/cmake-build-debug/Image/";
    path_image += "new_game.png";
    std::ifstream fin;
    fin.open(path_image);
    bool check = true;
    if (!fin.is_open()){
        check = false;
    }
    ASSERT_EQUAL(check, true);
}

CTEST(suite2, test35) {
    std::string path_image = "../../Blaster/cmake-build-debug/Image/";
    path_image += "new_game_star.png";
    std::ifstream fin;
    fin.open(path_image);
    bool check = true;
    if (!fin.is_open()){
        check = false;
    }
    ASSERT_EQUAL(check, true);
}

CTEST(suite2, test36) {
    std::string path_image = "../../Blaster/cmake-build-debug/Image/";
    path_image += "panel.png";
    std::ifstream fin;
    fin.open(path_image);
    bool check = true;
    if (!fin.is_open()){
        check = false;
    }
    ASSERT_EQUAL(check, true);
}

CTEST(suite2, test37) {
    std::string path_image = "../../Blaster/cmake-build-debug/Image/";
    path_image += "player.png";
    std::ifstream fin;
    fin.open(path_image);
    bool check = true;
    if (!fin.is_open()){
        check = false;
    }
    ASSERT_EQUAL(check, true);
}

CTEST(suite2, test38) {
    std::string path_image = "../../Blaster/cmake-build-debug/Image/";
    path_image += "rocket.png";
    std::ifstream fin;
    fin.open(path_image);
    bool check = true;
    if (!fin.is_open()){
        check = false;
    }
    ASSERT_EQUAL(check, true);
}

CTEST(suite2, test39) {
    std::string path_image = "../../Blaster/cmake-build-debug/Image/";
    path_image += "space.png";
    std::ifstream fin;
    fin.open(path_image);
    bool check = true;
    if (!fin.is_open()){
        check = false;
    }
    ASSERT_EQUAL(check, true);
}

CTEST(suite2, test40) {
    std::string path_image = "../../Blaster/cmake-build-debug/Image/";
    path_image += "space1.png";
    std::ifstream fin;
    fin.open(path_image);
    bool check = true;
    if (!fin.is_open()){
        check = false;
    }
    ASSERT_EQUAL(check, true);
}



//аудио
CTEST(suite3, test1) {
    std::string path_audio = "../../Blaster/cmake-build-debug/Audio/";
    path_audio += "BASTA.mp3";
    std::ifstream fin;
    fin.open(path_audio);
    bool check = true;
    if (!fin.is_open()){
        check = false;
    }
    ASSERT_EQUAL(check, true);
}

CTEST(suite3, test2) {
    std::string path_audio = "../../Blaster/cmake-build-debug/Audio/";
    path_audio += "game over.mp3";
    std::ifstream fin;
    fin.open(path_audio);
    bool check = true;
    if (!fin.is_open()){
        check = false;
    }
    ASSERT_EQUAL(check, true);
}

CTEST(suite3, test3) {
    std::string path_audio = "../../Blaster/cmake-build-debug/Audio/";
    path_audio += "paf.wav";
    std::ifstream fin;
    fin.open(path_audio);
    bool check = true;
    if (!fin.is_open()){
        check = false;
    }
    ASSERT_EQUAL(check, true);
}

CTEST(suite3, test4) {
    std::string path_audio = "../../Blaster/cmake-build-debug/Audio/";
    path_audio += "roblox.mp3";
    std::ifstream fin;
    fin.open(path_audio);
    bool check = true;
    if (!fin.is_open()){
        check = false;
    }
    ASSERT_EQUAL(check, true);
}

CTEST(suite3, test5) {
    std::string path_audio = "../../Blaster/cmake-build-debug/Audio/";
    path_audio += "bufk.wav";
    std::ifstream fin;
    fin.open(path_audio);
    bool check = true;
    if (!fin.is_open()){
        check = false;
    }
    ASSERT_EQUAL(check, true);
}

